import cookies from '@/utils/store/cookies'
import { tokenName, appName } from '@/setting'
const userCookies = {
    /**
     * @description 获取cookies信息
     */
    get: function (name = tokenName, isJson = false) {
        let value = cookies.get(`${appName}-${name}`)
        if (isJson && value) {
            value = JSON.parse(value)
        }
        return value;
    },
    /**
     * @description 设置cookies信息
     * @param {any} data cookie 数据
     */
    set: function (value: any, name = tokenName, { isJson = false, expires = 1 } = {}) {
        if (isJson) {
            value = JSON.stringify(value)
        }
        // console.log(name, value)
        cookies.set(`${appName}-${name}`, value, {
            expires
        })
    },
    /**
      * @description 清空cookies
      *
      */
    remove: function (name = tokenName) {
        cookies.remove(`${appName}-${name}`);
    }
}

export default userCookies;